package com.example.administrator.myapplication;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.example.administrator.myapplication.bean.ScoreBean;
import com.example.administrator.myapplication.biz.ScoreBiz;
import com.example.administrator.myapplication.util.ToastUtil;
import com.example.administrator.myapplication.view.StartGameSurfaceView;

/**
 * Created by Administrator on 2016/3/16 0016.
 */
public class StartGameActivity extends Activity {
    private int mImageId;
    private int mLevel;
    private ScoreBiz mScoreBiz;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);


        Intent intent = getIntent();
        mImageId = intent.getExtras().getInt("imageId");
        mLevel = intent.getExtras().getInt("level");
        StartGameSurfaceView sg = new StartGameSurfaceView(this,mImageId,mLevel);
        setContentView(sg);
        ToastUtil.show(this,"等级："+mLevel+"图片ID"+mImageId);
        mScoreBiz = new ScoreBiz(this);


    }
    //携带数据跳转
    public void startActivity(int level,long score)
    {
        //如果这个成绩进入该等级的前10，跳转留下大名的界面，否则 直接关闭
        //查询这个等级的第10名的分数  如果没有 或者 查出来的分数大于该分数   则进入了前10
        ScoreBean bean = mScoreBiz.queryScoreByLevel(level);
        if(null==bean || bean.getScore()>score)
        {
            Intent intent = new Intent(this, WinActivity.class);
            intent.putExtra("level", level);
            intent.putExtra("time", score);
            startActivity(intent);
        }

        finish();
    }
}
